<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <f:view>
        <h:head>
            <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
            <link href="#{request.contextPath}/resources/css/style.css" rel="stylesheet" type="text/css" />
            <title>RBH-Risk</title>
        </h:head>

        <h:body>
            <p:blockUI block="center" widgetVar="buiLayout"/>
            <pe:layout id="layoutId" stateCookie="false" widgetVar="fpLayoutWidget">
                <pe:layoutPane position="center" id="center">
                    <div align="center">
                        <ui:insert name="content"/>
                    </div>
                </pe:layoutPane>

                <pe:layoutPane position="east" size="260">
                    <h:form id="formNavLeftId">
                        <pe:layoutPane position="north"
                                       styleContent="text-align: left; font-size: smaller; font-weight: lighter; margin: 0px">
                            <f:facet name="header">
                                <h:outputText value="User is {#{navigatorBean.profile.opduser.loginname}}"/>
                            </f:facet>
                            <ui:repeat value="#{navigatorBean.profile}" var="p">
                                <h:outputText value="ชื่อ : #{p.opduser.name}"/><p:separator/>
                                <h:outputText value="ตำแหน่ง : #{p.opduser.entryposition}"/><p:separator/>
                                <h:outputText value="ระดับการเข้าถึง : #{p.role.roleNameTH}"/><p:separator/>
                                <h:outputText value="เข้าใช้งานล่าสุด : "/>
                                <h:outputText value="#{p.profileLastAccessDatetime}"><p:separator/>
                                    <f:convertDateTime type="date" locale="th_TH" pattern="dd/MM/yyyy HH:mm"/>
                                </h:outputText>
                            </ui:repeat>
                        </pe:layoutPane>

                        <pe:layoutPane position="center">
                            <f:facet name="header">
                                <h:outputText value="navigator"/>
                            </f:facet>
                            <h:panelGrid columns="1" style="width: 100%; font-size: small">
                                <p:panelMenu style="font-size: small; text-align: left" rendered="#{privilegeBean.backend()}">
                                    <p:submenu label="Administrator Tools">
                                        <p:menuitem value="Setting Profile" icon="ui-icon-gear" 
                                                    onclick="javascript:location.href='settingProfile.xhtml'"/>
                                    </p:submenu>
                                </p:panelMenu>
                                <p:commandButton value="บันทึกรายงานความเสี่ยง" icon="ui-icon-circle-arrow-e"
                                                 action="#{riskAddBean.destroy}" ajax="false"
                                                 style="vertical-align: bottom; width: 100%; text-align: left"/>
                                <p:commandButton value="ดูบัญชีความเสี่ยง" icon="ui-icon-circle-arrow-e" ajax="false"
                                                 style="vertical-align: bottom; width: 100%; text-align: left" 
                                                 action="#{riskListBean.reset}"/>
                                <p:commandButton value="ดูสรุปรายการความเสี่ยง" rendered="#{privilegeBean.viewReport()}"
                                                 action="#{riskSummaryBean.reset()}" icon="ui-icon-circle-arrow-e"
                                                 style="vertical-align: bottom; width: 100%; text-align: left" ajax="false"/>
                                <p:commandButton value="ออกจากระบบ" icon="ui-icon-circle-arrow-e" ajax="false"
                                                 onclick="javascript:location.href='#{request.contextPath}/j_spring_security_logout'"
                                                 style="vertical-align: bottom; width: 100%; text-align: left"/>
                            </h:panelGrid>
                        </pe:layoutPane>

                        <pe:layoutPane position="south">
                            <p:poll interval="60" update="topReportId" />
                            <p:dataTable id="topReportId" var="tops" rowIndexVar="no" styleClass="borderGrid"
                                         scrollable="true" scrollHeight="150"
                                         style="width: 100%; font-size: small; text-align: left; margin: 0px"
                                         value="#{navigatorBean.topReportList}">
                                <f:facet name="header">Risk Top 20 Report</f:facet>
                                <p:column style="text-align: left; width: 80%">
                                    <h:outputText value="#{no+1}.#{tops.fullname}" />
                                </p:column>
                                <p:column style="text-align: center; width: 20%">
                                    <h:outputText value="#{tops.point}" />
                                </p:column>
                            </p:dataTable>
                        </pe:layoutPane>
                    </h:form>
                </pe:layoutPane>

                <pe:layoutPane position="south" closable="false" resizable="false">
                    <h:outputText value="Power By RBH@Website"/>
                </pe:layoutPane>
            </pe:layout>
        </h:body>
    </f:view>
</html>